import request from '@/libs/request';

/**
 * 用户登录
 * @param {*} data
 * @returns
 */
export const login = data => {
  return request({
    url: '/user/login',
    method: 'post',
    data: data
  })
}

/**
 * 用户列表
 * @returns
 */
export const UserList = data => {
  return request({
    url: `/user/list`,
    method: 'post',
    data: data
  })
}

/**
 * 根据token获取用户信息
 * @param {*} data
 * @returns
 */
export const getUserInfo = data => {
  return request({
    url: `/user/info`,
    method: 'get',
    data: data
  })
}

/**
 * 根据user_id获取用户信息
 * @param {*} data
 * @returns
 */
export const getUserDetail = data => {
  return request({
    url: `/user/${data.user_id}/info`,
    method: 'get',
    data: data
  })
}

/**
 * 注册用户
 * @param {*} data
 * @returns
 */
export const register = data => {
  return request({
    url: `/user/register`,
    method: 'post',
    data: data
  })
}

/**
 * 修改用户信息
 * @param {*} data
 * @returns
 */
export const editUser = data => {
  return request({
    url: `/user/${data.user_id}/info`,
    method: 'put',
    data: data
  })
}

/**
 * 修改用户密码
 * @param {*} data
 * @returns
 */
export const updatePassword = data => {
  return request({
    url: `/user/password`,
    method: 'put',
    data: data
  })
}

/**
 * 删除用户信息
 * @param {*} data
 * @returns
 */
export const deleteUser = data => {
  return request({
    url: `/user/${data.user_id}/info`,
    method: 'delete',
    data: data
  })
}
